#include "PopupLoginMsg.hpp"

using namespace Popup;

LoginMsg::LoginMsg(const Message *p_message)
: AbstractMessage(POPUP_MSG_TYPE_LOGIN, POPUP_ENCRYPTION_BLOWFISH)
{
  AbstractMessage::deserialize(p_message);
}

bool LoginMsg::onSend()
{
  return (AbstractMessage::payloadAddString(LOGIN, login) &&
          AbstractMessage::payloadAddString(PASSWORD, password) &&
          AbstractMessage::payloadAddBoolean(CREATEUSER, createUser));
}

bool LoginMsg::onReceive()
{
  return ((fields.size() == 3) &&
      (AbstractMessage::payloadGetString(LOGIN, login)) &&
      (AbstractMessage::payloadGetString(PASSWORD, password)) &&
      (AbstractMessage::payloadGetBoolean(CREATEUSER, createUser)));
}
